<?php
Class View {
	private $layout;
	private $context;
	public function show($tpl,$params=array())
	{
		extract($params);
		include($tpl);
		ob_start();
		if($this->layout)
		{
			include($this->layout);
		}
		$html = ob_get_clean();
		$filename = md5($tpl);
		//file_put_contents(ROOT.'/cache/'.$filename.'.html', $html);
		echo $html;exit;
	}

	public function layout($tpl)
	{
		$this->layout = $tpl;
	}

	public function yields($key)
	{
		echo $this->context[$key];
	}

	public function section($key)
	{
		$this->buf = $key;
		ob_start();
	}

	public function stop()
	{
		$this->context[$this->buf] = ob_get_clean();
		$this->buf = '';
	}
}